﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

using WS.EKA.Core.Attributes;

namespace WS.EKA.ServiceInterface
{
    /// <summary>
    /// Base service interface
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IService<T>
    {
        /// <summary>
        /// Save entity
        /// </summary>
        /// <param name="entity"></param>
        [Logger]
        //[Transaction]
        void Save(T entity);

        /// <summary>
        /// Get entity by primary key
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>Entity</returns>
        T Get(params object[] keys);

        /// <summary>
        /// Get paged entity list
        /// </summary>
        /// <param name="pageIndex">Page Index</param>
        /// <param name="pageSize">Page Size</param>
        /// <param name="filter">Lamda filter condition</param>
        /// <param name="order">Order by column</param>
        /// <param name="recordTotal">return total record count</param>
        /// <returns>Entity List</returns>
        List<T> GetByPage(int pageIndex, int pageSize, Expression<Func<T, bool>> filter, Func<IQueryable<T>, IOrderedQueryable<T>> order, out int recordTotal);

        void Delete(Expression<Func<T, bool>> filter);

        void Delete(int id);

        T Get(Expression<Func<T, bool>> func, Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null);
    }
}
